<%@ page language="java" import="com.bifrii.bo.*,com.bifrii.dao.*,com.bifrii.transferObjects.*,java.util.*" %>
<%
	
	String name = request.getParameter("nameEvent"); 
	String description = request.getParameter("description"); 
	String limitAssistance = request.getParameter("limitAssistance");
	String avatar = request.getParameter("avatar");
	String idCommunity = request.getParameter("idCommunity");
	
	if(name=="" || avatar=="" || description=="" || limitAssistance=="" || idCommunity ==""){
		out.println("rellenar todo");
		response.sendRedirect("FrontController?res=newEvent.jsp");
	}
	
	if(EventManager.getInstance().testEvent(name)){
		
		Event e = new Event();
		e.setName(name);
		e.setIdCommunity(Integer.parseInt(idCommunity));
		e.setDescription(description);
		e.setLimitAssistance(Integer.parseInt(limitAssistance));
		e.setAvatar(avatar);
		
		session.setAttribute("session.newEvent", e);
		
		if(session.getAttribute("session.routesList")==null)
		{
			List<Route> lista = new ArrayList<Route>();
			session.setAttribute("session.routesList", lista);
		}
		
		out.println("Evento Creado");
		response.sendRedirect("newRoutesIntoEvent.jsp");
	}else{
		out.println("ya existe el evento");
		
		response.sendRedirect("newEvent.jsp");
		
	}
%>

